package com.lindroy.androidplayer.ui.adapter

import android.annotation.SuppressLint
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.DiffUtil
import com.lindroy.androidplayer.base.adapter.BasePagingAdapter
import com.lindroy.androidplayer.databinding.ProjectItemBinding
import com.lindroy.androidplayer.logic.model.ProjectListResp
import com.lindroy.androidplayer.viewmodels.ProjectItemViewModel

/**
 * @author Lin
 * @date 2022/1/20
 * @function
 */
class ProjectAdapter(lifecycleOwner: LifecycleOwner) :
    BasePagingAdapter<ProjectItemViewModel, ProjectItemBinding>(lifecycleOwner,
        object : DiffUtil.ItemCallback<ProjectItemViewModel>() {
            override fun areItemsTheSame(
                oldItem: ProjectItemViewModel,
                newItem: ProjectItemViewModel
            ): Boolean = oldItem.id == newItem.id

            @SuppressLint("DiffUtilEquals")
            override fun areContentsTheSame(
                oldItem: ProjectItemViewModel,
                newItem: ProjectItemViewModel
            ): Boolean = oldItem == newItem
        }) {

    override fun ProjectItemBinding.onBindViewHolder(item: ProjectItemViewModel?, position: Int) {
        this.vm = item
    }
}
